package cn.demoncat.util.http.entity;

import cn.demoncat.util.io.FileNameUtil;
import cn.demoncat.util.lang.ParamEmptyUtil;

/**
 * HTTP 文件参数
 * 
 * @author 延晓磊
 *
 * @since 2019年10月12日
 */
public class HttpFileParam {

	/**
	 * 文件
	 */
	private byte[] file;
	/**
	* 名称
	*/
	private String name;
	/**
	 * ContentType = MediaType = MimeType
	 */
	private String contentType;
	
	
	public HttpFileParam() {
		super();
	}
	
	public HttpFileParam(byte[] file, String name) {
		this(file, name, null);
	}
	
	public HttpFileParam(byte[] file, String name, String contentType) {
		super();
		this.file = file;
		this.name = name;
		this.contentType = contentType;
		// 参数校验
		ParamEmptyUtil.checkBlank(name);
		if (contentType == null) {
			this.contentType = FileNameUtil.getMimeType(name);
		}
	}
	
	public byte[] getFile() {
		return file;
	}
	public void setFile(byte[] file) {
		this.file = file;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public String getContentType() {
		return contentType;
	}
	public void setContentType(String contentType) {
		this.contentType = contentType;
	}
	
}
